// Code generated by ent, DO NOT EDIT.

package region

import (
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the region type in the database.
	Label = "region"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldName holds the string denoting the name field in the database.
	FieldName = "name"
	// FieldParentRegion holds the string denoting the parentregion field in the database.
	FieldParentRegion = "parent_region"
	// FieldLatitude1 holds the string denoting the latitude1 field in the database.
	FieldLatitude1 = "latitude1"
	// FieldLongitude1 holds the string denoting the longitude1 field in the database.
	FieldLongitude1 = "longitude1"
	// FieldLatitude2 holds the string denoting the latitude2 field in the database.
	FieldLatitude2 = "latitude2"
	// FieldLongitude2 holds the string denoting the longitude2 field in the database.
	FieldLongitude2 = "longitude2"
	// FieldOsmData holds the string denoting the osmdata field in the database.
	FieldOsmData = "osm_data"
	// EdgeRegionType holds the string denoting the regiontype edge name in mutations.
	EdgeRegionType = "regionType"
	// EdgeAccountId holds the string denoting the accountid edge name in mutations.
	EdgeAccountId = "accountId"
	// Table holds the table name of the region in the database.
	Table = "regions"
	// RegionTypeTable is the table that holds the regionType relation/edge.
	RegionTypeTable = "regions"
	// RegionTypeInverseTable is the table name for the RegionType entity.
	// It exists in this package in order to avoid circular dependency with the "regiontype" package.
	RegionTypeInverseTable = "region_types"
	// RegionTypeColumn is the table column denoting the regionType relation/edge.
	RegionTypeColumn = "region_region_type"
	// AccountIdTable is the table that holds the accountId relation/edge.
	AccountIdTable = "regions"
	// AccountIdInverseTable is the table name for the User entity.
	// It exists in this package in order to avoid circular dependency with the "user" package.
	AccountIdInverseTable = "users"
	// AccountIdColumn is the table column denoting the accountId relation/edge.
	AccountIdColumn = "region_account_id"
)

// Columns holds all SQL columns for region fields.
var Columns = []string{
	FieldID,
	FieldName,
	FieldParentRegion,
	FieldLatitude1,
	FieldLongitude1,
	FieldLatitude2,
	FieldLongitude2,
	FieldOsmData,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "regions"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"region_region_type",
	"region_account_id",
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

// OrderOption defines the ordering options for the Region queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldName, opts...).ToFunc()
}

// ByParentRegion orders the results by the parentRegion field.
func ByParentRegion(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldParentRegion, opts...).ToFunc()
}

// ByLatitude1 orders the results by the latitude1 field.
func ByLatitude1(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLatitude1, opts...).ToFunc()
}

// ByLongitude1 orders the results by the longitude1 field.
func ByLongitude1(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLongitude1, opts...).ToFunc()
}

// ByLatitude2 orders the results by the latitude2 field.
func ByLatitude2(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLatitude2, opts...).ToFunc()
}

// ByLongitude2 orders the results by the longitude2 field.
func ByLongitude2(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLongitude2, opts...).ToFunc()
}

// ByRegionTypeField orders the results by regionType field.
func ByRegionTypeField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newRegionTypeStep(), sql.OrderByField(field, opts...))
	}
}

// ByAccountIdField orders the results by accountId field.
func ByAccountIdField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newAccountIdStep(), sql.OrderByField(field, opts...))
	}
}
func newRegionTypeStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(RegionTypeInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, RegionTypeTable, RegionTypeColumn),
	)
}
func newAccountIdStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(AccountIdInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, AccountIdTable, AccountIdColumn),
	)
}
